package com.cnpc.bds.sdk.sink.kafka.support;

import org.apache.commons.lang3.StringUtils;

/**
 * ApiAssert.
 */
public class Assert {

    public static void notBlank(String arg, String error) {
        if (StringUtils.isBlank(arg)) {
            throw new IllegalArgumentException(error);
        }
    }

    public static void noneBlank(String error, String... args) {
        for (String arg : args) {
            if (StringUtils.isBlank(arg)) {
                throw new IllegalArgumentException(error);
            }
        }
    }

    public static void hasNotBlank(String error, String... args) {
        for (String arg : args) {
            if (StringUtils.isNotBlank(arg)) {
                return;
            }
        }
        throw new IllegalArgumentException(error);
    }

    public static void hasNotNull(String error, Object... args) {
        for (Object arg : args) {
            if (arg != null) {
                return;
            }
        }
        throw new IllegalArgumentException(error);
    }

    public static void notNull(Object arg, String error) {
        if (arg == null) {
            throw new IllegalArgumentException(error);
        }
    }

    public static void state(boolean accept, String error) {
        if (!accept) {
            throw new IllegalArgumentException(error);
        }
    }
}
